package com.wms.controller;

import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.dto.InspectDto;
import com.wms.entity.ArrivalQualityInspection;
import com.wms.service.ArrivalQualityInspectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "csy到货质检")
@RequestMapping("/api")
public class InspectController {
    @Autowired
    ArrivalQualityInspectionService arrivalQualityInspectionService;

    @ApiOperation("根据到货单获取质检信息")
    @GetMapping("/arrival/getInspect")
    @ApiImplicitParam(name = "arrivalId",value = "到货单id")
    public ResultBean getInspectByArrivalId(@RequestParam(required = true) int arrivalId){
        List<ArrivalQualityInspection> list=arrivalQualityInspectionService.queryInspectById(arrivalId);
        return R.success("质检信息",list);
    }
    @ApiOperation("根据id更新质检信息")
    @PutMapping("/inspect/changeById/{id}")
    @ApiImplicitParam(name = "id",value = "质检单id",required = true,dataType = "int")
    public ResultBean updateInspectById(@PathVariable(required = true) int id,@RequestBody InspectDto inspectDto){
        int rs=arrivalQualityInspectionService.updateInspectById(inspectDto);
        inspectDto.setId(id);
        return rs==1?R.success("更新成功"):R.fail("更新失败");
    }
}
